package main
import (
	"fmt"
	"net"
)

func main(){
	
	/*监听*/
	lt, err := net.Listen("tcp", "127.0.0.1:8000")
	if err != nil{
		fmt.Println("Listen err : ", err)
		return
	}
	fmt.Println("Link TCP 127.0.0.1:8000 OK")
	defer lt.Close()
	
	/*阻塞*/
	for{
		conn, err1 := lt.Accept()
		if err1 != nil{
			fmt.Println("Accept err ：", err1)
			continue
		}
		defer conn.Close()
		
		/*输出*/
		buf := make([]byte, 1024)
		num, err2 := conn.Read(buf)
		if err2 != nil{
			fmt.Println("Read err ：", err2)
			continue
		}
		fmt.Printf("TCP客户端发来数据：%s\n", buf[:num])
	}
}